/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package bookstore.action;
import com.opensymphony.xwork2.Action;
import bookstore.iservice.*;
import bookstore.service.*;
import bookstore.idao.*;
import bookstore.dao.*;
import bookstore.model.*;
import com.opensymphony.xwork2.ActionContext;
/**
 *
 * @author cjx
 */
public class CustomerAction_0 implements Action
{
   private ICustomerService bsCustomerService =new CustomerService();
   private String name;
   private String pass;
   private String msg;
   public void setName(String name){this.name=name;}
   public void setPass(String pass){this.pass=pass;}
   
   public String execute()
   {
       bsCustomerService.setCustomerDao(new CustomerDao());
       Customer bsCustomer=bsCustomerService.findCustomerByNameAndPassword(name,pass);   
       if(bsCustomer==null)
       {
          msg=ERROR;
         ActionContext.getContext().getSession().put("msg","the Current User is Guest");
       }
       else
         {
             msg=SUCCESS;
             ActionContext.getContext().getSession().put("bsCustomer",bsCustomer);
          }
       return msg;
   }
    
}
